<%--
  Created by IntelliJ IDEA.
  User: longl
  Date: 2020/8/19
  Time: 15:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="basePath.jsp"%>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>ProClinic-医院管理系统Bootstrap4前端框架</title>
    <!-- Fav  Icon Link -->
    <link rel="shortcut icon" type="image/png" href="${basePath}afsets/images/fav.png">
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="${basePath}afsets/css/bootstrap.min.css">
    <!-- themify icons CSS -->
    <link rel="stylesheet" href="${basePath}afsets/css/themify-icons.css">
    <!-- Animations CSS -->
    <link rel="stylesheet" href="${basePath}afsets/css/animate.css">
    <!-- Main CSS -->
    <link rel="stylesheet" href="${basePath}afsets/css/styles.css">
    <link rel="stylesheet" href="${basePath}afsets/css/green.css" id="style_theme">
    <link rel="stylesheet" href="${basePath}afsets/css/responsive.css">
    <!-- morris charts -->
    <link rel="stylesheet" href="${basePath}afsets/charts/css/morris.css">
    <!-- jvectormap -->
    <link rel="stylesheet" href="${basePath}afsets/css/jquery-jvectormap.css">
    <link rel="stylesheet" href="${basePath}afsets/datatable/dataTables.bootstrap4.min.css">

    <script src="${basePath}afsets/js/modernizr.min.js"></script>
</head>

<body>
<!-- Pre Loader -->
<div class="loading">
    <div class="spinner">
        <div class="double-bounce1"></div>
        <div class="double-bounce2"></div>
    </div>
</div>
<!--/Pre Loader -->
<!-- Color Changer -->
<div class="theme-settings" id="switcher">
		<span class="theme-click">
			<span class="ti-settings"></span>
		</span>
    <span class="theme-color theme-default theme-active" data-color="green"></span>
    <span class="theme-color theme-blue" data-color="blue"></span>
    <span class="theme-color theme-red" data-color="red"></span>
    <span class="theme-color theme-violet" data-color="violet"></span>
    <span class="theme-color theme-yellow" data-color="yellow"></span>
</div>
<!-- /Color Changer -->
<div class="wrapper">
    <!-- Page Content -->
    <div id="content">
        <!-- Top Navigation -->
        <div class="container top-brand">
            <nav class="navbar navbar-default">
                <div class="navbar-header">
                    <div class="sidebar-header"> <a href="index.html"><img src="${basePath}afsets/imagles/ogo-dark.png" class="logo" alt="logo"></a>
                    </div>
                </div>
                <ul class="nav justify-content-end">
                    <%@include file="loginOut_head.jsp"%>
                </ul>

            </nav>
        </div>
        <!-- /Top Navigation -->
        <!-- Menu -->
        <div class="container menu-nav">
            <nav class="navbar navbar-expand-lg lochana-bg text-white">
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
                        aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="ti-menu text-white"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul class="navbar-nav mr-auto">
                        <%@include file="headHTML.jsp"%>
                    </ul>
                </div>
            </nav>
        </div>
        <!-- /Menu -->
        <!-- Breadcrumb -->
        <!-- Page Title -->
        <div class="container mt-0">
            <div class="row breadcrumb-bar">
                <div class="col-md-6">
                    <h3 class="block-title">欢迎：${username}</h3>
                    <a>
                        (
                        <shiro:hasRole name="SUPERADMINISTATOR">
                            <a>超级管理员</a>
                        </shiro:hasRole>
                        <shiro:hasRole name="ADMINISTATOR">
                            <a>管理员</a>
                        </shiro:hasRole>
                        <shiro:hasRole name="USER">
                            <a>普通用户</a>
                        </shiro:hasRole>
                        )
                    </a>
                </div>
            </div>
        </div>
        <!-- /Page Title -->

        <!-- /Breadcrumb -->
        <!-- Main Content -->
        <div class="container">

            <div class="row">
                <!-- Widget Item -->
                <div class="col-md-12" style="text-align: center;">
                    <div class="widget-area-2 lochana-box-shadow">
                        <div id="update-data"></div>
                        <div >
                            <c:forEach items="${roles}" var="role">
                                <a class="btn btn-primary" href="${basePath}power/queryAllAuthority?id=${role.id}&roleDesc=${role.roleDesc}">${role.roleDesc}&nbsp;</a>
                            </c:forEach>
                        </div>
                        <div class="table-responsive mb-3">
                            <caption>${empty sysRole.roleDesc ? '所有权限':sysRole.roleDesc}</caption>
                            <table id="tableId" class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <th class="no-sort">
                                        <div class="custom-control custom-checkbox">
                                            <input class="custom-control-input" type="checkbox" id="select-all">
                                            <label class="custom-control-label" for="select-all"></label>
                                        </div>
                                    </th>
                                    <th>名称</th>
                                    <th>资源路径</th>
                                    <th>是否拥有权限</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach items="${resourcesMap}" var="resourcesEntry">
                                    <c:set var="resource" value="${resourcesEntry.key}"/>
                                    <c:set var="isResource" value="${resourcesEntry.value}"/>
                                    <tr>
                                        <td>
                                            <div class="custom-control custom-checkbox">
                                                <input class="custom-control-input" type="checkbox">
                                                <label class="custom-control-label"></label>
                                            </div>
                                        </td>
                                        <td>${resource.userName}</td>
                                        <td>${resource.resUrl}</td>
                                        <td>
                                            <c:if test="${not empty sysRole.roleDesc}">
                                                <input type="radio" onclick="addAuthority(${sysRole.id}, ${resource.id},'${sysRole.roleDesc}', this)" name="has_+${resource.id}" ${isResource==1?'checked':''} value="1"/>是
                                                <input type="radio" onclick="addAuthority(${sysRole.id}, ${resource.id},'${sysRole.roleDesc}', this)" name="has_+${resource.id}" ${isResource==0?'checked':''} value="0"/>否
                                            </c:if>
                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <!-- /Widget Item -->
            </div>
        </div>
        <!-- /Main Content -->
        <!--Copy Rights-->
        <!-- /Copy Rights-->
    </div>
    <!-- /Page Content -->
</div>
<!-- Back to Top -->
<a id="back-to-top" href="#" class="back-to-top">
    <span class="ti-angle-up"></span>
</a>
<!-- /Back to Top -->
<!-- Jquery Library-->
<script src="${basePath}afsets/js/jquery-3.2.1.min.js"></script>
<!-- Popper Library-->
<script src="${basePath}afsets/js/popper.min.js"></script>
<!-- Bootstrap Library-->
<script src="${basePath}afsets/js/bootstrap.min.js"></script>

<!-- Datatable  -->
<script src="${basePath}afsets/datatable/jquery.dataTables.min.js"></script>
<script src="${basePath}afsets/datatable/dataTables.bootstrap4.min.js"></script>

<!-- Custom Script-->
<script src="${basePath}afsets/js/custom.js"></script>
<script src="${basePath}afsets/js/custom-datatables.js"></script>
<script>
    function addAuthority(roleId, resourcesId, roleDesc, obj) {
        window.location.href = "${basePath}power/addAuthority?roleId="+roleId+"&resourcesId="+resourcesId+"&has="+obj.value+"&roleDesc="+roleDesc;
    }
</script>
</body>

</html>
